<template>
    <div>
        <h2>物流相关信息</h2>
        <div class="logistics-info-header">
            <div class="logistics-info-header-left">
                <div class="logistics-status blue" :style="statusColor">{{ statusText }}</div>
                <div class="logistics-company">{{ logistics.logisticsCompany }}</div>
                <div class="logistics-no">{{ logistics.logisticsNo }}</div>
            </div>
        </div>
        <ul class="logistics-info-list">
            <li v-for="(item, index) in logistics.logisticsInfo" :key="index">
                <div class="logistics-info-list-time">{{ item.time }}</div>
                <div class="logistics-info-list-content">{{ item.content }}</div>
            </li>
        </ul>
        <button v-check="logistics.role">查看物流详情</button>
    </div>
</template>
<script>
export default {
    props: ['logistics'],
    data() {
        return {
        };
    },
    computed: {
        statusColor() {
            switch (this.logistics.logisticsStatus) {
                case 0:
                    return { color: 'red' }; // 未发货
                case 1:
                    return { color: 'orange' }; // 已发货
                case 2:
                    return { color: 'green' }; // 已签收
                case 3:
                    return { color: 'blue' }; // 未签收
                default:
                    return { color: 'black' }; // 默认颜色
            }
        },
        statusText() {
            switch (this.logistics.logisticsStatus) {
                case 0:
                    return '未发货';
                case 1:
                    return '已发货';
                case 2:
                    return '已签收';
                case 3:
                    return '未签收';
                default:
                    return '未知状态';
            }
        }
    },
    directives: {
        check: {
            inserted(el, binding) {
                console.log(el, binding);
                el.addEventListener('click',function(){
                    if(binding.value=='admin'|| binding.value=='zhangsan'){
                        alert('校验通过')
                    }
                    else alert('无权限')
                })
            }
        }
    }
};
// 快件运单号

</script>
<style scoped>
.logistics-info {
    border: 1px solid #ccc;
    border-radius: 5px;
    box-shadow: 0px 0px 10px #eee;
    padding: 10px;
    font-size: 14px;
}

.logistics-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.logistics-info-header-left {
    display: flex;
    align-items: center;
}

.logistics-status {
    font-weight: bold;
    font-size: 16px;
    color: #007bff;
}

.logistics-company,
.logistics-no {
    margin-left: 10px;
    font-size: 14px;
    color: #333;
}

.logistics-info-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 230px;
    overflow-y: auto;
}

.logistics-info-list li {
    display: flex;
    margin-bottom: 10px;
}

.logistics-info-list-time {
    font-size: 12px;
    color: #999;
    width: 80px;
    text-align: right;
    margin-right: 10px;
}

.logistics-info-list-content {
    font-size: 14px;
    color: #333;
}
</style>